// $Id: ExportPreview.cs 67 2008-05-07 21:07:39Z nvivo $

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using Fireball.Windows.Forms; // Where is located CodeEditorControl class
using Fireball.Syntax; // Where is located SyntaxDocument class
using Fireball.CodeEditor.SyntaxFiles;

namespace DBLGen.GUI.Forms
{
	public partial class ExportPreview : Form
	{
		private ExportDataCollection _exportDataCollection;

		protected override void OnLoad(EventArgs e)
		{
			//this.codeEditorControl1 = new CodeEditorControl();
			//this.codeEditorControl1.Dock = DockStyle.Fill;
			//this.codeEditorControl1.TabSize = 2;
			//this.codeEditorControl1.Document = this.syntaxDocument1;
			//CodeEditorSyntaxLoader.SetSyntax(this.codeEditorControl1, SyntaxLanguage.XML);
			
			base.OnLoad(e);
		}

		public ExportPreview(ExportDataCollection edc)
		{
			if (edc == null)
				throw new ArgumentNullException("edc");

			_exportDataCollection = edc;

			InitializeComponent();
		}

		private void btnClose_Click(object sender, EventArgs e)
		{
			Close();
		}

		private void ExportPreview_Load(object sender, EventArgs e)
		{
			foreach (ExportData ed in _exportDataCollection)
			{
				CodeEditorControl ctr = new CodeEditorControl();
				SyntaxDocument ctrDoc = new SyntaxDocument();
				ctrDoc.Text = ed.Contents;
				ctr.Dock = DockStyle.Fill;
				ctr.TabSize = 2;
				ctr.Document = ctrDoc;
				CodeEditorSyntaxLoader.SetSyntax(ctr, SyntaxLanguage.CSharp);

				TabPage page1 = new TabPage();
				page1.Text = ed.FileName;
				page1.Controls.Add(ctr);
				tabPreview.TabPages.Add(page1);
				tabPreview.Dock = DockStyle.Fill;

				//TextBox txt = new TextBox();
				//txt.Text = ed.Contents;
				//txt.Font = new Font(FontFamily.GenericMonospace, 10);
				//txt.Dock = DockStyle.Fill;
				//txt.Multiline = true;
				//txt.ReadOnly = true;
				//txt.BackColor = SystemColors.Window;
				//txt.ScrollBars = ScrollBars.Both;
				//txt.WordWrap = false;


				//TabPage page = new TabPage();
				//page.Text = ed.FileName;
				//page.Controls.Add(txt);

				//tabPreview.TabPages.Add(page);
			}
		}
	}
}